package com.eight.travel.controller;

import com.eight.travel.pojo.Store;
import com.eight.travel.service.StoreService;
import com.eight.travel.utils.BaseResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@Api(value = "商场模块")
public class StoreController {
    @Autowired
    StoreService storeService;

    //通过商场id查询
    @ApiOperation(value = "通过商场id查询",notes = "需传入 商场id")
    @GetMapping("/Store/findByID")
    public BaseResp selectByID(Integer sid){
        return storeService.selectByID(sid);
    }

    //全查（分页）
    @ApiOperation(value = "分页全查商场信息",notes = "需传入 当前页page和显示行数size")
    @GetMapping("/Store/findAll")
    public BaseResp selectAll(Integer page, Integer limit){
        return storeService.selectAll(page, limit);
    }

    //添加商场
    @ApiOperation(value = "添加商场",notes = "需传入 商场信息")
    @PostMapping("/Store/insertStore")
    @ResponseBody
    public BaseResp addStore(@RequestBody Store store){
        return storeService.addStore(store);
    }

    //动态修改商场信息
    @ApiOperation(value = "修改商场信息(动态修改)",notes = "需传入 商场信息")
    @PostMapping("/Store/updateStore")
    @ResponseBody
    public  BaseResp updateStore(@RequestBody Store store){
        return storeService.updateStore(store);
    }

    //通过id删除一条商场信息
    @ApiOperation(value = "通过id删除一条商场信息",notes = "需传入 商场id")
    @PostMapping("/Store/deleteByID")
    public BaseResp deleteByID(Integer sid){
        return storeService.deleteByID(sid);
    }

    //点击增加商场热度
    @ApiOperation(value = "点击增加商场热度",notes = "需传入 商场id")
    @PostMapping("/Store/updateStorehot")
    public BaseResp updateStorehot(Integer sid){
        return storeService.updateStorehot(sid);
    }

    //商场热度排序
    @ApiOperation(value = "商场热度排序",notes = "需传入 当前页page和显示行数size")
    @GetMapping("/Store/findByHot")
    public BaseResp selectByHot(Integer page, Integer limit){
        return storeService.selectByHot(page, limit);
    }

    //通过商场名模糊查询
    @ApiOperation(value = "通过商场名模糊查询",notes = "需传入 模糊查询的商场名")
    @GetMapping("/Store/findByLike/{storename}")
    public BaseResp selectByLike(@PathVariable("storename") String storename){
        return storeService.selectByLike(storename);
    }
}
